package cn.shadow.test;

import javafx.collections.ObservableList;
import javafx.collections.transformation.SortedList;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

public class Person implements Comparable<Person>{
    String name;
    public Person(String name){
        this.name=name;
    }

    @Override
    public int compareTo(Person o) {
        return name.compareTo(o.name);
    }

    public static void main(String[] args) {
        List<Person> peopleList = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            peopleList.add(new Person("" + i));
        }
        Collections.shuffle(peopleList);
        Collections.sort(peopleList);
        SortedList<Person> sortedList = new SortedList<>((ObservableList<? extends Person>) peopleList, Comparator.comparing(o -> o.name));
    }
}
